<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            border-spacing: collapse;

        }

        tr {
            border-spacing: collapse;
        }

        td {
            width: 50px;
            height: 50px;
            border: 1px solid red;
        }
    </style>
</head>

<body>

    <script>
        // 6、生成任意表格
        var row = prompt("请输入行数") - 0
        var col = prompt('请输入列数') - 0

        if (row > 0 && col > 0) {
            document.write('<table>')
            for (var i = 0; i < row; i++) {
                document.write('<tr>')
                for (var j = 0; j < col; j++) {
                    document.write('<td> </td>')
                }
                document.write('</tr>')
            }
            document.write('</table>')
        }
    </script>
</body>

</html>